package com.origin.app.business.net

import android.content.Intent
import android.view.View
import androidx.databinding.ObservableField
import com.origin.app.R
import com.origin.app.databinding.ActivityNetBinding
import com.origin.baselibrary.activity.style.ViewModelActivity
import java.io.File

class NetActivity : ViewModelActivity<ActivityNetBinding, NetViewModel>(R.layout.activity_net) {


    val log = ObservableField<String>()

    fun clearLog(view: View) {
        log.set("")
    }

    fun netRequest(view: View) {
        viewModel.netRequest(log)
    }

    fun netDownload(view: View) {
//        val logFile = this@NetActivity.getExternalFilesDir("app")
//        val file = File(logFile!!.absolutePath + "/" + "a.apk")
//        viewModel.netDownload(file)
        startActivity(Intent(this,DownLoadActivity::class.java))
    }

//    override fun contentView(): Int = R.layout.activity_net
    override fun initContentView() {
        contentViewBinding.log = log
        viewModel.progressInfo.observe(this, {
            log.set(it)
        })
    }
}